package com.tocea.formation.others;

import java.util.*;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;

public class Dates {
	static Locale locale = Locale.getDefault();
	static Date actuelle = new Date();
	
	static DateFormat  format = new SimpleDateFormat("yyyy-MM-dd");
	
	public static String dateActuelle(){
		String dat = format.format(actuelle);
		return dat;
	}
	
	public static String dateToString(Date date){
		return format.format(date);
	}
	
	public static Date stringToDate(String sDate){
		sDate = sDate + " 00:00:00";
		try {
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			ParsePosition pos = new ParsePosition(0);
			Date d = formatter.parse(sDate,pos);
			return d;
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
		return null;	 	
	}

}
